<%--
  Created by IntelliJ IDEA.
  User: 1
  Date: 2023-3-6
  Time: 8:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fm" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/status/js/jquery.js"></script>
</head>
<body>
<script>
    $(function () {
        var tt = true;
        $.getJSON("${pageContext.request.contextPath}/user/xlklist",function (date) {
            var str = "<option value=\"\">请选择</option>";
            $("#bmid").html("");
            for(var i = 0;i<date.length;i++){
                str+="<option value=\""+date[i].id+"\">"+date[i].bmname+"</option>";
            }
            $("#bmid").append(str);
        })
        $("#account").blur(function () {
            $.getJSON("${pageContext.request.contextPath}/user/select",{"account":$("#account").val()},function (date) {
                if(date){
                    $("#idd").text("账号不可用");
                    tt = false;
                }else {
                    $("#idd").text("账号可用");
                    tt = true;
                }
            })
        })
        $("form").submit(function () {
            if(!tt){
                return false;
            }
            if($("[name=list]:checked").length==0){
                $("#skill").text("技能必须至少一个");
                return false;
            }
            if($("#account").val()==""){
                $("#idd").text("账号不能为空");
                return false;
            }
        })
    })
</script>
    <fm:form method="post" action="${pageContext.request.contextPath}/user/adds" enctype="multipart/form-data">
        头像：<input type="file" name="file"><span>${error}</span><br>
        账号：<input type="text" name="account" id="account"><i id="idd"></i><br/>
        姓名：<fm:input path="realname"/><fm:errors path="realname"/><br/>
        手机号：<fm:input path="phone"/><fm:errors path="phone"/><br/>
        性别：<fm:radiobutton path="sex" value="1"/>男
        <fm:radiobutton path="sex" value="0"/>女<fm:errors path="sex"/><br/>
        生日：<input type="date" name="birthday"><fm:errors path="birthday"/><br/>
        个人介绍：<fm:textarea path="ms"/><fm:errors path="ms"/><br/>
        所属部门：<fm:select path="bmid" id="bmid">

                </fm:select><fm:errors path="bmid"/><br/>
        技能：<fm:checkbox path="list" value="java"/>java
        <fm:checkbox path="list" value="php"/>php
        <fm:checkbox path="list" value="html"/>html <i id="skill"></i><br/>
        <input type="submit" value="提交"><a href="#" >退回</a>
    </fm:form>
</body>
</html>
